<template>
  <div class="warp">
    <div class="top">
      <div class="resource container">
        <div class="block text-center">
          <el-carousel style="width: 1200px; height: 466px">
            <el-carousel-item style="width: 1200px; height: 466px">
              <img
                src="https://rs.dance365.com/photo/1667210329871.jpg?imageView2/0/w/2000/h/1200/format/webp/ignore-error/1"
                alt=""
              />
            </el-carousel-item>
            <el-carousel-item>
              <img
                src="https://rs.dance365.com/photo/1667373574669.jpg?imageView2/0/w/2000/h/1200/format/webp/ignore-error/1"
                alt=""
              />
            </el-carousel-item>
          </el-carousel>
        </div>

        <AvocationSelector
          :dialogVisible="dialogVisible"
          @handleDialog="handleDialog"
        />
      </div>
      <el-affix :offset="0">
        <div class="elmenuWrap">
          <el-menu
            mode="horizontal"
            :default-active="activeIndex"
            style="display: flex; justify-content: center; align-items: center"
            bg-color="#fff"
            text-color="#7d8090"
            active-text-color="#111"
            class="el-menu-demo"
            @select="handleSelect"
            router="true"
          >
            <el-menu-item index="/resource/recommend" class="elmenuItem"
              >推荐</el-menu-item
            >
            <el-menu-item index="/resource/production" class="elmenuItem">
              作品</el-menu-item
            >
            <el-menu-item index="/resource/teach" class="elmenuItem">
              教程</el-menu-item
            >
            <el-menu-item index="/resource/topic" class="elmenuItem"
              >专题</el-menu-item
            >
            <el-menu-item index="/resource/active" class="elmenuItem"
              >动态</el-menu-item
            >
            <el-menu-item index="/resource/watch" class="elmenuItem"
              >关注</el-menu-item
            >
            <el-menu-item
              :index="`/resource/${item.id}`"
              class="elmenuItem"
              v-for="item in selectedAvocationList"
              :key="item.id"
              >{{ item.name }}</el-menu-item
            >
          </el-menu>
          <div class="elButton">
            <el-button text @click="handleDialog" style="font-size: 16px;background-color: #fff;">
              选择兴趣技能</el-button
            >
          </div>
        </div>
      </el-affix>
    </div>
    <div>
      <div class="bottom">
        <div class="routerView container">
          <router-view></router-view>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent } from 'vue';

export default defineComponent({
  name: 'Resource',
});
</script>

<script setup lang="ts">
import { ref } from 'vue';
import { reactive, onMounted } from 'vue';
// import {reqInterestList} from "@/api/resource";
// import type {interestContent,interestData} from "@/api/parctice/interestType";
import { ElMessageBox } from 'element-plus';
import { useMineStore } from '@/store/mine/mine';
import { storeToRefs } from 'pinia';

const activeIndex = ref('1');

const dialogVisible = ref(false);
const handleDialog = () => {
  dialogVisible.value = !dialogVisible.value;
};
const handleSelect = (key: string, keyPath: string[]) => {
  console.log(key, keyPath);
};

// 从仓库中拿到选中的列表
const useMine = useMineStore();
// console.log(useMine,'1111');

// useMine.setSelectedAvocationList();
let { selectedAvocationList } = storeToRefs(useMine);
console.log(selectedAvocationList.value, '00');
</script>

<style scoped lang="less">
.warp {
  width: 100%;
  background-color: #ffffff;
  .block {
    height: 466px;
    .el-carousel__item {
      border-radius: 4px;
      width: 1200px;
      height: 466px;
      cursor: pointer;
    }
    img {
      width: 1200px;
      height: 466px;
    }
  }
  .elmenuWrap {
    position: relative;
    height: 35px;
    .elmenuItem {
      font-size: 18px;
    }
    width: 1200px;
    margin: 0 auto;
    .elButton {
      height: 50px;
      position: absolute;
      display: inline-block;
      right: 160px;
      top: 8px;
      font-size: 18px;
      vertical-align: middle;
      padding: 0;
      z-index: 10;
      background-color: #ffffff;
    }
  }
  .tags {
    height: 300px;
    overflow: auto;
    .tagList {
      display: flex;
      margin-top: 20px;
      .tagItem {
        display: inline-block;
        min-width: 100px;
        height: 40px;
        line-height: 38px;
        text-align: center;
        border-radius: 4px;
        border: 1px solid #eaecf0;
        color: #111;
        background-color: #fff;
        cursor: pointer;
        margin: 0 22px 21px 0;
        display: inline-block;
        font-size: 12px;
        position: relative;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        span {
          display: inline-block;
          padding: 0 22px;
          -webkit-box-sizing: border-box;
          box-sizing: border-box;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        .toggle-interest-icon {
          cursor: pointer;
          position: absolute;
          width: 20px;
          height: 20px;
          top: -10px;
          right: -10px;
          background: pink;
          display: block;
        }
        .toggle-interest-icon.icon {
          display: none;
        }
      }
    }
  }
  .dialog-footer {
    button {
      padding: 20px 40px;
      margin-right: 10px;
    }
    .first {
      color: #737478;
      background-color: #fff;
    }
    .first:hover {
      color: aliceblue;
      background-color: #ffd3e5;
      border: 1px solid #ea8db0;
    }
    .last {
      color: aliceblue;
      background-color: #ff619e;
    }
    .last:hover {
      border: 1px solid #ea8db0;
    }
  }
  .bottom {
    width: 100%;
    background-color: #f5f7f9;
    .routerView {
      padding-top: 10px;
    }
  }
}
</style>
